package com.zzj.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zzj.entity.User;
import com.zzj.mapper.UserMapper;
import com.zzj.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author zzj
 * @since 2023-11-14
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {

    @Override
    public User findByUsername(String username) {
        return this.getOne(Wrappers.<User>lambdaQuery().eq(User::getUsername, username), false);
    }
    @Override
    public User findByEmail(String email) {
        return this.getOne(Wrappers.<User>lambdaQuery().eq(User::getEmail, email), false);
    }

    @Override
    public User findById(int id) {
        return this.getOne(Wrappers.<User>lambdaQuery().eq(User::getId, id), false);
    }

    @Override
    public User findByOpenid(String openid) {
        return this.getOne(Wrappers.<User>lambdaQuery().eq(User::getOpenid, openid), false);
    }
}
